package com.sumainfor.pc.epc.service.impl.gmio;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.epc.dao.GmioSearchEpcMapper;
import com.sumainfor.pc.epc.feign.Zfeign.ZpcMktFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务管家工作台搜索
 * <p>
 *
 * @author: zc
 * @create: 2019-09-19 14:45
 **/
@Service
public class GmioSearchEpcService implements Serializable {

    @Autowired
    GmioSearchEpcMapper gmioSearchEpcMapper;

    @Autowired
    ZpcMktFeign zpcMktFeign;

    /**
     * 根据房源编号查询新房验收
     * @author zhoucong
     * @data 2019/9/19
     * @Param
     * @return
     */
    public List<Map<String,Object>> getHoDecorateFugjList(String search){
        //查询管家验房列表
        List<Map<String,Object>> epcList=gmioSearchEpcMapper.getHoDecorateFugjList(search);
        Map<String,Object> params = new HashMap<>();
        //保存房源编号
        List<String> hIdList=new ArrayList<String>();
        for (Map<String,Object> map: epcList){
            if(map.get("HouId")!=null){
                hIdList.add(map.get("HouId").toString());
            }
        }
        params.put("hIdList",hIdList);
        //根据房源编号查询房源的信息
        JsonResult marketResut=zpcMktFeign.getHouIdInfoList(params);
        if (marketResut.get("errorCode").toString().equals("0")){
            List<Map<String,Object>> marketList=(List<Map<String,Object>>)marketResut.get("result");
            for (Map<String,Object> map1:epcList){
                if (map1.get("HouId")!=null){
                    for (Map<String,Object> map2:marketList){
                        if (map2.get("HouId")!=null){
                            if (map1.get("HouId").toString().equals(map2.get("HouId").toString())){
                                map1.putAll(map2);
                            }
                        }
                    }
                }

            }
        }
        return epcList;

    }



    /**
     * 根据租客idList查询维修申请
     * @author zhoucong
     * @data 2019/9/19
     * @Param
     * @return
     */
    public List<Map<String,Object>> getFugjRepairList(Map<String,Object> params){
        return gmioSearchEpcMapper.getFugjRepairList(params);
    }



}
